import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/exam/ExamPartStartPromptPage.dart';
import 'package:ichinesereader/exam/ExamSectionPage.dart';
import 'ExamQuestionIndexPage.dart';
import 'controllers/ExamPageController.dart';

///
/// *Part 试卷章节， 最高级别的 章节
//
class ExamPartPage extends GetView<ExamPageController> {
  const ExamPartPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Log.debug('ExamPartPage build');

    return Container(
      padding: const EdgeInsets.all(0),
      child: _buildExamPartContent(),
    );
  }

  Widget _buildExamPartContent() {
    return Obx(() {
      Log.debug('ExamPartPage _buildExamPartContent');
      Widget? partContent;
      // ignore: unused_local_variable
      var currentQuestionStepIndex = controller.currentQuestionStepIndex.value;
      UiQuestionStep? uiQuestionStep = controller.currentQuestionStep;
      if (uiQuestionStep?.stepType == UiQuestionStep.STEPTYPE_PARTPROMPT) {
        partContent = const ExamPartStartPromptPage();
      } else if (uiQuestionStep?.stepType == UiQuestionStep.STEPTYPE_QUESTION) {
        partContent = const ExamSectionPage();
      } else {
        partContent = const Center(
          child: CircularProgressIndicator(),
        );
      }
      return partContent;
    });
  }
}
